<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.trkj.com/tr1702/tags" prefix="my" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定义组织</title>
	<style type="text/css">
		 
	</style>
</head>
<body>
<script type="text/javascript">
			 var dialogedit =function(){
				 <my:g id="78"> 
					$("<form method='get'>").appendTo(document.body).form({
						url:'definetissue_update',
						onSubmit:function(param){
						var vv=$('#cf-definetissue-tb').datagrid('getSelected'); 	 
							//alert(vv.organiId+" "+vv.organiName);		
							 
							param['organiId'] = vv.organiId;
							param['organiName'] =$('#cf-definetissue-name').textbox('getText');
							param['organiRemarks'] =$('#cf-definetissue-remarks').textbox('getText');
						},
						success:function(){
							$("#cf-definetissue-tb").datagrid("reload");
							$("#cf-definetissue-win").dialog("close");
						}
					}).submit().appendTo(".abc");
					</my:g> 
			}
			var formatters=function(value,row,index){
				<my:g id="77"> 
				var edit= "<a button='grid-butt-edit' onclick='delrow("+row.organiId+")'>删除</a>";
				</my:g> 
				return edit;
			}
			var delrow= function(organiId){
				$.messager.confirm('提示','确定要删除这一行',function(v){
					 if(v){
						 $.post("definetissue_remove",{organiId:organiId},function(){
							 $('#cf-definetissue-tb').datagrid('reload');
						 });
					 }
				});
			}
			$(function(){
				$("#cf-definetissue-tb").datagrid({onLoadSuccess:function(){
					$("a[button=grid-butt-edit]").linkbutton({iconCls:'icon-cancel',plain:true});
				}});
				//添加
				$("#cf-definetissue-add").linkbutton({
					onClick : function() {
						$("#cf-definetissue-win").dialog("open");
						$('#cf-definetissue-id').textbox('setValue',"");
						$('#cf-definetissue-name').textbox('setValue',"");
						$('#cf-definetissue-remarks').textbox('setValue',"");
						/* parent.$('.dialog-button a:eq(1)').hide();
						parent.$('.dialog-button a:eq(0)').show();  */
						$('#cf-dyzz-1').show();
						$('#cf-dyzz-2').hide();
						$('#cf-definetissue-win').dialog('setTitle', '添加组织');
					}
				});
				$("#cf-definetissue-refresh").linkbutton({onClick:function(){
					 $('#cf-definetissue-tb').datagrid('reload');
				}});
				$("#cf-definetissue-tb").datagrid({
					onDblClickRow : function(index,row) {
						var vv=	$('#cf-definetissue-tb').datagrid('getSelected');
						console.log(row.organiId);
			 			$('#cf-definetissue-id').textbox('setValue',row.organiId);
						$('#cf-definetissue-name').textbox('setValue',row.organiName);
						$('#cf-definetissue-remarks').textbox('setValue',row.organiRemarks);
						$('#cf-definetissue-win').dialog('open');
						// 隐藏
						/* parent.$('.dialog-button a:eq(0)').hide();
						parent.$('.dialog-button a:eq(1)').show(); */
						$('#cf-dyzz-1').hide();
						$('#cf-dyzz-2').show();
						$('#cf-definetissue-win').dialog('setTitle', '编辑组织');
					}
				});
				$('#cf-definetissue-tb').pagination({
					total: 114,
					buttons: [{
						iconCls:'icon-add',
						handler:function(){alert('add')}
					},'-',{
						iconCls:'icon-save',
						handler:function(){alert('save')}
					}]
				});


			});
	</script>
	<div class="abc"></div>
	<div id="cf-definetissue-tbs3">
		<my:g id="79"> 
   		 <a id="cf-definetissue-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,text:'添加'"></a>
    	 </my:g>
		<a id="cf-definetissue-refresh" class="easyui-linkbutton" data-options="iconCls:'icon-reload',text:'刷新',plain:true,iconAlign:'right'"></a>    	 
		<input class="easyui-searchbox" data-options="label:'搜索',width:300,labelWidth:50,prompt:'组织名称',
     	searcher:function(value,name){
	        $('#cf-definetissue-tb').datagrid('load','definetissue_searchbox?organiName='+value);
     	 }">
  </div>
		<table id="cf-definetissue-tb" class="easyui-datagrid" data-options="
			url:'definetissuepages',
			fitColumns:true,
			fit:true,
			nowrap:false,
			loading:true,
			pagination:true,
			rownumbers:true,
			singleSelect:true,
			pageSize:10,
    		pageList:[10,20,30,40,50],
			toolbar:'#cf-definetissue-tbs3',
			striped:true,
			method:'get'	
	">
		<thead>
		  <tr>
			<th data-options="field:'organiId',width:200,align:'center'">组织编号</th>
			<th data-options="field:'organiName',width:200,align:'center'">组织名称</th>
			<th data-options="field:'organiRemarks',width:450,align:'center',
				styler:function(value,row,index){
					if(value==1){
						return 'color:white;background:red;';
					}
				}
			">备注</th>
			<th data-options="field:'organiTime',width:200,align:'center',
				formatter:function(value,row,index){
					//var unixTimestamp = new Date(value);
	            	//return unixTimestamp.toLocaleString();
	            	var date = new Date(value);
                        var y = date.getFullYear();
                        var m = date.getMonth() + 1;
                        var d = date.getDate();
                        return y + '-' +m + '-' + d;
				}
			">创建时间</th>
			<th data-options="field:'organiEndtime',width:200,align:'center',
				formatter:function(value,row,index){
					if(value!=null){
						 var date = new Date(value);
                        var y = date.getFullYear();
                        var m = date.getMonth() + 1;
                        var d = date.getDate();
                        return y + '-' +m + '-' + d;
					}	
				}
			">最后更新</th>
			<th data-options="field:'organiPerson',width:200,align:'center'">创建人</th>
			<th id="shanchu-butt" data-options="field:'1',width:150,align:'center',formatter:formatters"></th>
		  </tr>	
		</thead>
		<tbody>
			 
		</tbody>
	</table>
	
<div id="cf-definetissue-win" class="easyui-dialog"data-options="width:300, height:180,
			title:'添加组织',
     		bodyCls:'definetissueadd',
      		modal:true,
      		closed:true,
      		buttons:[{
	        	text:'提交',
				id:'cf-dyzz-1',
	        	iconCls:'icon-ok',
        		handler:function(){
          		 $('#cf-definetissue-f').form({
            		onSubmit:function(param){
            		 //验证表单
						var  cc=$('#cf-definetissue-id').textbox('getValue');
						
             		 return $(this).form('validate');
            		},
	           		 success:function(v){
	              		//$.messager.alert('提示','注册成功');
	              		$('#cf-definetissue-win').dialog('close');
					$('#cf-definetissue-tb').datagrid('reload');
	            	}
          	    }).submit();
       		  }
      		},{
        	text:'保存',
			id:'cf-dyzz-2',
        	iconCls:'icon-save',

	        	handler:dialogedit
			},{
        	text:'取消',
        	iconCls:'icon-cancel',
	        	handler:function(){
	          		$('#cf-definetissue-win').dialog('close');
	        	}
			}
			]">
		<form id="cf-definetissue-f" action="definetissueadd" method="get">
			<div class="line">
				        <input id="cf-definetissue-id" class="easyui-textbox" name="organiId"
					data-options="label:'组织编号',width:250,required:true">
			</div>
			
			<div class="line">
				        <input id="cf-definetissue-name" class="easyui-textbox" name="organiName"
					data-options="label:'组织名称',width:250">
			</div>
			
			<div class="line">
				        <input id="cf-definetissue-remarks" class="easyui-textbox" name="organiRemarks"
					data-options="label:'备注',width:250">
			</div>
		</form>
	</div>

</body>
</html>